#version 410 core
uniform bool isTex;
uniform sampler2D s;

uniform vec3 specular_albedo = vec3(0.7);
uniform vec3 ambient = vec3(0.3);
uniform float specular_power = 128.0;

out vec4 fColor;

in VS_OUT{
    vec3 color;
    vec2 uv;
    vec3 N;
    vec3 L;
    vec3 V;
} fs_in;

void main()
{
    vec3 N = normalize(fs_in.N);
    vec3 L = normalize(fs_in.L);
    vec3 V = normalize(fs_in.V);
    vec3 R = reflect(-L,N);

    vec3 diffuse = max(dot(N,L),0.0) * fs_in.color;

    vec3 specular = pow(max(dot(R,V),0.0),specular_power) * specular_albedo;

    if(!isTex){
        fColor = vec4(ambient + diffuse + specular , 1.0);
    }else{
        fColor = texture(s, fs_in.uv);
    }
}
